import { Component, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-todo-header',
  templateUrl: './todo-header.component.html',
  styleUrls: ['./todo-header.component.css'],
})
export class TodoHeaderComponent {
  @Output() public addTodoEvent = new EventEmitter<string>();
  constructor() {}

  public addTodo(todoName: string, el: HTMLInputElement) {
    if (todoName.trim() === '') return;
    this.addTodoEvent.emit(todoName);
    el.value = '';
  }
}
